//
//	 RansacMethod.h
//
#ifndef __H_RANSACMETHOD_H__
#define __H_RANSACMETHOD_H__


#define EPS1 2.220446049250313e-16
#define EPS2 0.000001
//void ppp( double * , double * , double * , 
//		  double * , int , int);
//void sss( double * , double *);
//int svd( double * , int , int , double * , double * ,
//	     double , int);
void ppp( double a[], double e[], double s[], 
		  double v[], int m, int n );
void sss( double fg[], double cs[]);
int svd( double a[], int m, int n, double u[], double v[],
	     double eps, int ka );

int matinv(double ** , int);

class Ransac
{
public:
	Ransac(void);
	Ransac(double ** , double ** , int, double);
	void Normalize(double ** , double ** , double ** , double **);
	void MainLoop(double ** , double ** , int , int , double , double ** , int * , int & , int &);
	void MatrixMul(double ** , int , int , double ** , int , int , double **);
	void fitHomography(double**, double**, int, double**);
	void getInliers(double ** , double ** , int , double ** , double , int * , int & , int & );
public:
	~Ransac(void);

private:
	double mean(double * , int);
	void Normalize(double ** , int , double ** , double **);
	void randgen(int , int , int *);
	bool isdegenerate(double ** , int);
	bool iscolinear(double * , double * , double *);
	void cross(double * , double * , double *);
	double magnitude(double *, int);

private:
	double ** m_X1;	//3xNOE
	double ** m_X2;	//3xNOE
	int m_NOF;
	double m_Threshold;
	double ** m_H;
	int i , j , k; 
};


#endif